home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #9
/
Amiga Plus CD - 2004 - No. 09.iso
/
amigaplus
/
tools
/
amigaos4_only
/
ifxlite
/
imagefx3
/
rexx
/
find.ifx
< prev
next >
Wrap
Text File
|
2004-08-03
|
1KB
|
65 lines
/*
* $VER: Find 3.0 (13.2.98)
*
* Arexx program for the ImageFX image processing system.
* Written by Thomas Krehbiel
*
* This program will find and activate the nearest palette color for
* the pixel that the user clicks the mouse over. Demonstrates the use
* of the WAITFOR command.
*
*/
OPTIONS RESULTS
/* Save current color, because we're going to trash it */
GetPalette '-1'
PARSE VAR result oldr oldg oldb
LockInput ; LockGui
Message 'Select a location'
/* Pick color, wait for user to pick something */
Pick
WaitFor SELECTUP
/* Find out what we got, save it */
GetPalette '-1'
PARSE VAR result dstr dstg dstb
/* Restore original palette color */
SetPalette '-1' oldr oldg oldb
UnlockGui
/* Now look through the palette for the closest match. This is
a fairly elementary matching routine, since we don't happen
to have square roots available in standard REXX. */
bestdist = 999999
bestcol = 0
BeginBar 'Finding' 1
DO i = 0 TO 31
GetPalette i
PARSE VAR result r g b
dist = ABS(r - dstr) + ABS(g - dstg) + ABS(b - dstb)
IF dist < bestdist THEN DO
bestdist = dist
bestcol = i
END
END
EndBar
ActiveColor bestcol
UnlockInput
EXIT